if (!GGServer.Class.io) GGServer.Class.io = {};
GGServer.Class.io.Cookie = function() {
    this.get = function(Name) {
        GetCookieValue(Name);
    };
    this.oget = function(name) {
        GetCookieValue(name);
    };
    this.set = function(name, value) {
        writeCookie(name, value, '', 365, '/');
    };
    this.del = function(name) {
        writeCookie(name, value, '', -1, '/');
    };
    this.readCookie = function(name) {
        GetCookieValue(name);
    };
}
function SetTipInfo(obj, info, iswrongtip) {
    if (iswrongtip) {//错误提示
        obj.innerHTML = '<span class="c2"><span class="action_po"><span class="action_po_top">' + info + '</span><span class="action_po_bot"></span></span></span>';
        obj.className = '';
    }
    else {//输入提示
        obj.innerHTML = '<span class="c1"><span class="action_po"><span class="action_po_top">' + info + '</span><span class="action_po_bot"></span></span></span>';
        obj.className = 'action_po_top';
    }
}
function Show(upload, pid, cid) {
    try {
        if (upload == null) {
            upload = new GGServer.Class.webUI.uploadFile(clientID, "upload", "DivUpload", "returnInput", ClientPicList, 4);
        }
        upload.init();
    }
    catch (ex) {}
}
function AddHeight(t, pid, o) {
    var allowcount = o.allowcount;
    var count = o.ClientPicList.split('|').length;
    if (t == "init") {
        count = count - 1;
    }
    if (count >= allowcount) { return false; }
    if (count % 4 == 0) {
        var pdiv = document.getElementById(pid);
        pdiv.style.height = (pdiv.offsetHeight + 180) + "px";
    }
    return true;
}
function getPos(obj) {
    var x = obj.offsetLeft;
    var y = obj.offsetTop;
    var rect = [0, 0];
    var el = obj;
    while (el != null && el != document.body) {
        rect[0] = rect[0] + el.offsetLeft;
        rect[1] = rect[1] + el.offsetTop;
        el = el.offsetParent;
    }
    return rect;
}
function chkAll(o, name) {
    var chklist = document.getElementsByName(name);
    for (var i = 0; i < chklist.length; i++) {
        if (o.checked) {
            chklist[i].checked = true;
        }
        else {
            chklist[i].checked = false;
        }
    }
}
function checkCheckBox(name, chkCount, t) {
    var chklist = document.getElementsByName(name);
    var j = 0;
    for (var i = 0; i < chklist.length; i++) {
        if (chklist[i].checked) {
            j++;
        }
    }
    if (t == 0) {
        return j >= chkCount;
    }
    else { return chkCount >= j; }
}
function initCheck(idstr, name) {
    try {
        var chklist = document.getElementsByName(name);
        var idlist = idstr.split(',');
        for (var j = 0; j < idlist.length; j++) {
            for (var i = 0; i < chklist.length; i++) {
                if (chklist[i].value == idlist[j]) {
                    chklist[i].checked = true;
                    break;
                }
            }
        }
    }
    catch (ex) {}
}
function chkTag(o, c, m) {
    var chklist = document.getElementsByName(o.name);
    var k = 0;
    for (var j = 0; j < chklist.length; j++) {
        if (chklist[j].checked) {
            k++;
        }
    }
    var tt = 2;
    if (c) {
        tt = c;
    }
    var mm = "只能选择2个标签";
    if (m) {
        mm = m;

    }
    if (chknum && !c && !m) {
        tt = chknum;
        mm = "只能选择" + chknum + "个标签";
        if (chkTagName) {
            mm = "只能选择" + chknum + "个" + chkTagName;
        }
    }
    if (k > tt) {
        o.checked = false;
        alert(mm);
    }
}

function checkCode(code,ischeck) {
        if (!code) {
            code = document.getElementById("codeText").value;
        }
        if (code != "") {
            document.getElementById("codeText").value = code = QuanToBan(code);
        }
        if (code.length == 5) {
            var urllink = "/ajax?";
            var post = "&action=verifycode&";
            post += "infoid=" + finfoid + "&";
            post += "code=" + code + "&";
            post += "&rand=" + new Date();
            urllink += post;
            $.post(urllink, {},
                function(data, textStatus) {
                    showCheckCodeResult(data.toString());
                }, "html");
        }
        else {
            if (code.length > 5) {
                SetTipInfo(document.getElementById("codeText_message"), "请输入正确的验证码", true);
            }
            else {
                try {
                    if (ischeck) {
                        SetTipInfo(document.getElementById("codeText_message"), "请输入正确的验证码", true);
                    } else {
                        SetTipInfo(document.getElementById("codeText_message"), "不区分大小写", false);
                    }
                } catch (E) {
                alert(E);
                 return true; }
            }
        }
}
function showCheckCodeResult(text)
{
    var msgobj = document.getElementById("codeText_message");
    if (text == "1") {
        if (msgobj) {
            msgobj.innerHTML = "";
            msgobj.className = "chenggong";
        }
        return true;
    }
    else {
        if (text == "false") {
            reloadImg();
        }
        else {
            if (msgobj) {
                SetTipInfo(msgobj, "验证码错误", true);
            }
        }
        return false;
    }
}
        
function clearcheck(name) {
//    var chklist = document.getElementsByName(name);
//    for (var j = 0; j < chklist.length; j++) {
//        chklist[j].checked = false;
//    }
    $("input[name=" + name + "]").attr("checked",false);
}

function disable(disabeldArray, t) {
    try {
        var disarray = disabeldArray.split('|');
        for (var i = 0; i < paraarray.length; i++) {
            var obj = paraarray[i];
            if (obj.type == "radio") { continue; }
            if (obj.type == "hidden") { continue; }
            if (obj.id == "Title" || obj.id == 'UserTag1' || obj.id == 'UserTag2' || obj.id.indexOf('_message') != -1) { continue; }
            var find = false;
            for (var j = 0; j < disarray.length; j++) {
                if (obj.id == disarray[j]) {
                    changeState(obj, t);
                    find = true;
                    break;
                }
            }
            if (find) { continue; }
            if (t == 0) { changeState(obj, 1); }
            else { changeState(obj, 0); }
        }
    }
    catch (ex) {}
}

function changeState(obj, t) {
    if (!obj) { return; }
    if (!obj.style) { return; }
    if (t == 0) {
        obj.style.display = '';
        obj.disabled = false;
        if (obj.type == "text" && up == "0") {
            if (!$(obj).attr("Except")) {
                obj.value = '';
            }
            else {
                if ($(obj).attr("Except") != "null") {
                    obj.value = $(obj).attr("Except");
                }
                else {
                    obj.value = "";
                }
            }
        }
    }
    else {
        obj.style.display = 'none';
        if (obj.type == "text" && up == "0") {
            obj.value = '[|#|@]';
        }
        else {
            try {
                if (obj.name && obj.name == "oldlevel") {
                    obj.disabled = true;
                }
            }
            catch (ex) { }
        }
    }
}
function subInit() {
    for (var i = 0; i < paraarray.length; i++) {
        if (paraarray[i] && paraarray[i].style.display == 'none' && paraarray[i].type == "text") {
            paraarray[i].value = '[|#|@]';
        }
    }
}
function initPara() {
    paraarray = [];
    var obj = document.getElementById("formTb");
    initPara1(obj.getElementsByTagName("span"));
    initPara1(obj.getElementsByTagName("tr"));
    initPara1(obj.getElementsByTagName("input"));
    initPara1(obj.getElementsByTagName("select"));
}
function initPara1(nodes) {
    for (var i = 0; i < nodes.length; i++) {
        if ($(nodes[i]).attr("id")) {
            paraarray[paraarray.length] = nodes[i];
        }
    }
}

function initEffectiveDate() {
    var hidEffectiveDate = document.getElementById("hidEffectiveDate");
    var EffectiveDate = document.getElementsByName("EffectiveDate")[0];
    if (EffectiveDate != null && hidEffectiveDate != null && hidEffectiveDate.value != "") {
        if (hidEffectiveDate.value == "7" || hidEffectiveDate.value == "30" || hidEffectiveDate.value == "100" || hidEffectiveDate.value == "365") {
            EffectiveDate.value = hidEffectiveDate.value;
        } 
    }
}

function initValue(hidid, p1, p2, t) {
    if (up == "0") { return; }
    var hid = document.getElementById(hidid);
    if (hid.value != "") {
        document.getElementById(p1).value = hid.value.split('-')[0];
        if (!t) {
            if (hid.value.split('-')[1]) {
                document.getElementById(p2).value = hid.value.split('-')[1];
            }
        }
    }
}
function initSubValue(s1, p1, p2, h, t) {
    if (!document.getElementById(s1) || !document.getElementById(p1) || !document.getElementById(p2) || !document.getElementById(h)) { return true; }
    var e1 = $("#"+p1).attr("Except");
    var e2 = $("#" + p2).attr("Except");
    try { cookie.set($("#" + h).attr("Name"), "[#except#]"); }
    catch (ex) { }
    if (e1 && e1 == document.getElementById(p1).value && document.getElementById(p1).style.display == '') {
        document.getElementById(h).value = document.getElementById(p1).value;
        return;
    }
    if (e2 && e2 == document.getElementById(p2).value && document.getElementById(p2).style.display == '') {
        document.getElementById(h).value = document.getElementById(p2).value;
        return;
    }
    if (document.getElementById(s1).style.display == '') {

        if (t == 0) {
            document.getElementById(h).value = document.getElementById(p2).value;
        }
        else {
            if (document.getElementById(p1).value != "" && document.getElementById(p2).value != "") {
                document.getElementById(h).value = document.getElementById(p1).value + "-" + document.getElementById(p2).value;
            }
        }
    }
    else {
        document.getElementById(h).value = document.getElementById(p1).value;
    }
}
function appendtitle(d, s, e, cc, z, p) {
    var value = "";
    if (s != "" && s != null) {
        value = s + "-";
    }
    if (e != "" && e != null) {
        value += e + " ";
    }
    if (cc != "" && cc != null) {
        value += cc + " ";
    }
    if (p != "" && p != null) {
        value += p;
    }
    if (z != "" && z != null) {
        value += z + "张";
    }
    if (d != "" && d != null) {
        value += " 发车日期:" + d;
    }
    if (document.getElementById("Title")) {
        document.getElementById("Title").value = value;
    }
}
function appendvalue() {
    var d, s, e, cc, z, p;
    var l = true;
    if (document.getElementById("StartTime")) {
        d = document.getElementById("StartTime").value;
    }
    if (document.getElementById("StartStation")) {
        s = document.getElementById("StartStation").value;
        if ($("#StartStation").attr("Except") == s) {
            s = "";
            l = false;
        }

    }
    if (document.getElementById("EndStation")) {
        e = document.getElementById("EndStation").value;
        if ($("#EndStation").attr("Except") == e) {
            e = "";
            l = false;
        }
    }
    if (document.getElementById("Num")) {
        cc = document.getElementById("Num").value;
    }
    if (document.getElementById("count")) {
        z = document.getElementById("count").value;
    }
    if (document.getElementById("ObjectType")) {
        p = $("#ObjectType option:selected").text();
    }
    appendtitle(d, s, e, cc, z, p);
}

function setLoginBlock() {
    window.onload = function() {
        initAll();
    }
}

function initAll() {
    CF = new GGServer.Class.Dom.CheckForms();
    CF.IsCheckForms.checkGroup("main");
    cookie = new GGServer.Class.io.Cookie();
/*    if (userid != "login") {
    alert("userid");
        var userstate = document.getElementById("daynote");
        if (userstate) {
            userstate.style.display = 'none';
        }
        if (document.all) {
            setbg('用户登录<span style=\"font-size:12px;font-weight:lighter\">( 登录后才能发布信息，没有账户，马上 <a style=\"color:#fff;text-decoration:underline;font-size:14px;\" onclick=\"javascript:document.getElementById(\\\'_58MessageBoxFrame\\\').src=\\\'http://my.58.com/simreg/?type=loginclose\\\';return false;\"><b>注册</b></a> )</span>', 410, 250, 'http://my.58.com/SimLogin/?type=loginclose', 'false');
        }
        else {
            setbg('用户登录<span style=\"font-size:12px;font-weight:lighter\">( 登录后才能发布信息，没有账户，马上 <a style=\"color:#fff;text-decoration:underline;font-size:14px;\" onclick=\"javascript:document.getElementById(\'_58MessageBoxFrame\').src=\'http://my.58.com/simreg/?type=loginclose\';return false;\"><b>注册</b></a> )</span>', 410, 250, 'http://my.58.com/SimLogin/?type=loginclose', 'false');
        }
    }*/
    if (document.all) {
        document.getElementById("formSubmit").src = "/submit.htm";
    }
    if (document.readyState == "complete" || !document.readyState) {
    	if (xl == 1) {
            xiaoqu = new inputAC("xiaoqu", "comdiv", "comframe", "xiaoqu", true, xqDataProvider, "<b>以下是您要填写的小区吗？</b>（点击选择）", "<b>没有匹配的小区</b>", "50%");

            xiaoqu.setupAC(document.getElementById("xiaoqu"), null);

        }
        if (rpp == 1) {
            pinpai = new inputAC("pinpai", "comdiv1", "comframe1", "erscpinpai", true, carDataProvider, "<b>以下是您要填写的品牌吗？</b>（点击选择）", "<b>没有匹配的品牌</b>", "25%");
            pinpai.setupAC(document.getElementById("erscpinpai"), null);
        }
        if (lb == 1) {

            CF.IsCheckForms.GetRelations(document.getElementById(lbi));
        }
        var A = window.frames["Editor"];
        if (!A || !A.E || A.E.complete != 1) {
            var B = document.getElementById("editorSpan");
            var C = document.getElementById("contentSpan");
            if (B) { B.style.display = 'none'; }
            if (C) { C.style.display = ''; }
        }
        var topImg = document.getElementById("topinfomsg");
        if (topImg) {
            var topHTML = cleraHTML(topImg.innerHTML);
            var topReg = new RegExp("(^\\s+$)", "ig");
            if (topReg.test(topHTML)||topHTML=="") {
                topImg.style.display = 'none';
            }
        }
    }
}
function cleraHTML(content) {
    var re = "<[\\s|\\S]+?>";
    var oReg = new RegExp(re, "ig");
    return content.replace(oReg,"");
 }
function showError(message) {
    alert(message);
    flagSubmit = false;
    document.getElementById('fabu').value = "发布"; document.getElementById('fabu').disabled = false;
    reloadImg();
}
function reloadImg(id) {
    var idd = "";
    if (!id) { idd = "cm"; }
    else { idd = id; }
    var img = document.getElementById(idd);
    if (!img) { img = document.getElementById("cmttt") }

    if (img) {
        img.src = "/code?new=" + new Date() + "&infoid=" + finfoid;
    }
}
function selectPhone(o) {
    document.getElementById("Phone").value = o.value;
}
function regvalue() {

    if (pinpai) {
        return pinpai.regvalue();
    }

    return true;
}

function SetFrameHeight(id, height) {
    var frame = document.getElementById(id);
    frame.style.height = height;
}
function ReloadFrame(id, url) {
    var iid = "gsInfo";
    if (id != "") {
        iid = id;
    }
    document.getElementById(iid).src = url;
}

var ti = 10;
function subValue() {
    var clientWin = document.getElementById("gsInfo").contentWindow;
    var result = '';
    if (clientWin.xmlHttp.readyState == 4) {
        if (clientWin.xmlHttp.status == 200) {
            result = clientWin.xmlHttp.responseText;
            if (result == "false") {
                alert("简历填写不正确");
                return false;
            }
            else if (result == "0") {
                alert("公司信息填写不正确");
                return false;
            }
        }
    }
    var retrunValue = result.split('|');
    document.getElementById("gongsi").value = retrunValue[0];
    if (!/^[1-9]+\d+$/.test(document.getElementById("gongsi").value)) {
        result = clientWin.getCompanyIdAndTradeId();
        retrunValue = result.split('|');
        document.getElementById("gongsi").value = retrunValue[0];
        if (!/^[1-9]+\d+$/.test(document.getElementById("gongsi").value)) {
            alert("提交出错，公司信息不正确");
            return false;
        }
    }
    if (retrunValue[1]) {
        document.getElementById("hangyeyaoqiu").value = retrunValue[1];
    }
    document.getElementById('aspnetForm').action = window.location.href + "/submit";
    document.getElementById('aspnetForm').submit();
    document.getElementById('fabu').disabled = true;
    document.getElementById('fabu').value = '正在发布...';
    return true;
}
function subzhaopininfo() {
    var youxiang = document.getElementById("jieshouyouxiang");
    var email = document.getElementById("Email");
    if (youxiang && email) {
        youxiang.value = email.value;
    }
    try { initSubValue("minxinzi", "minxinzi", "maxxinzi", "hidprice", 1); }
    catch (ex) { }
    var clientFrame = document.getElementById("gsInfo");
    if (!clientFrame || !clientFrame.contentWindow || !clientFrame.contentWindow.getMode) {
        alert("提交出错,公司信息不正确");
        return false;
    }
    var clientWin = clientFrame.contentWindow;
    if (!clientWin.getMode())//如果是展示
    {
        document.getElementById("gongsi").value = clientWin.getCompanyId();
        document.getElementById("hangyeyaoqiu").value = clientWin.getCompanyTradeId();
        if (!/^[1-9]+\d+$/.test(document.getElementById("gongsi").value)) {
            alert("提交出错，请与客服联系");
            return false;
        }
        return true;
    }
    if (!clientWin.checkInput()) {
        return false;
    }
    clientWin.subform(subValue);
    return false;
}
function subqiuzhiinfo() {
    try { initSubValue("minxinzi", "minxinzi", "maxxinzi", "hidprice", 1); } catch (ex) { }
    var clientFrame = document.getElementById("gsInfo");
    if (!clientFrame || !clientFrame.contentWindow || !clientFrame.contentWindow.getMode) {
        alert("提交出错，简历填写不正确");
        return false;
    }
    var clientWin = clientFrame.contentWindow;
    if (!clientWin.getMode())//如果是展示
    {
        document.getElementById("gongsi").value = clientWin.getCompanyId();
        if (!/^[1-9]+\d+$/.test(document.getElementById("gongsi").value)) {
            alert("提交出错，请与客服联系");
            return false;
        }
        return true;
    }
    if (!clientWin.checkInput()) {
        return false;
    }
    clientWin.subform(subValue);
    return false;
}
function dyniframesize(iframename) {
    var pTar = null;
    if (document.getElementById) {
        pTar = document.getElementById(iframename);
    }
    else {
        eval('pTar = ' + iframename + ';');
    }
    if (pTar && !window.opera) {
        pTar.style.display = "block"

        if (pTar.contentDocument && pTar.contentDocument.body.scrollHeight) {
            pTar.height = pTar.contentDocument.body.scrollHeight + 8;
        }
        else if (pTar.Document && pTar.Document.body.scrollHeight) {
            pTar.height = pTar.Document.body.scrollHeight + 8;
        }
    }
}
function showchild(typevalue, typename) {
    document.getElementById("gsInfo").contentWindow.chooseParentType(typevalue, typename);
}
function childtypeclick(typevalue, typename) {

    document.getElementById("gsInfo").contentWindow.chooseChildType(typevalue, typename);

}
function getAstro(month, day) {
    var s = "摩羯水瓶双鱼牡羊金牛双子巨蟹狮子处女天秤天蝎射手摩羯";
    var arr = [20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22];
    return s.substr(month * 2 - (day < arr[month - 1] ? 2 : 0), 2);
}
function get_animal(year) {
    if (year == '' || year == undefined) {
        return "";
    }
    var s = Math.abs((year - 1900) % 12);
    var animal = '';
    switch (s) {
        case 0: animal = '子鼠'; break;
        case 1: animal = '丑牛'; break;
        case 2: animal = '寅虎'; break;
        case 3: animal = '卯兔'; break;
        case 4: animal = '辰龙'; break;
        case 5: animal = '巳蛇'; break;
        case 6: animal = '午马'; break;
        case 7: animal = '未羊'; break;
        case 8: animal = '申猴'; break;
        case 9: animal = '酉鸡'; break;
        case 10: animal = '戌狗'; break;
        case 11: animal = '亥猪'; break;
    }
    return animal;
}
function getxiaoquname() {
    var value = document.getElementById("hidxiaoqu").value;
    if (/^\d+$/.test(value)) {
        lineDataProvider.getXiaoquName(value, "setxiaoquname('{data}')");
    }
    else {
        document.getElementById("xiaoqu").value = value;
    }
}
function setxiaoquname(data) {
    if (xiaoqu) {
        xiaoqu.Stop();
    }
    document.getElementById("xiaoqu").value = data;
}
function showtip() {
    var B = document.getElementById("Content");
    CF.IsCheckForms.ShowTip1(B);
}
function checkcontent() {
    var B = document.getElementById("Content");
    var A = window.frames["Editor"];
    B.value = A.E.G2();
    CF.IsCheckForms.CheckDefault1(B);
}
function setcontentvalue() {
    var B = document.getElementById("Content");
    var A = window.frames["Editor"];
    if (A && A.E && A.E.complete == 1) {
        B.value = A.E.G1();
    }
}
function qtb(B) {
    CF.IsCheckForms.QtoB1(B);
 }
function createditor(w, h) {
    var A = document.getElementById("editorSpan");
    if (A) {
        A.innerHTML = '<iframe src="/HtmlEditor/index.html?ID=Content&blur=checkcontent&focus=showtip" name="Editor" id="Editor" scrolling=no frameborder=0 height=' + h + ' width=' + w + '></iframe>';
    }
    setTimeout("closeEditor()", 5000);
}
function closeEditor() {
    var A = window.frames["Editor"];
    var close = false;
    if (!A) {
        close = true;
    }
    else {
        if (!A.E) {
            close = true;
        }
        else {
            if (A.E.complete == 0) {
                close = true;
            }
        }
    }
    if (close) {
        var B = document.getElementById("editorSpan");
        var C = document.getElementById("contentSpan");
        if (B) { B.style.display = 'none'; B.innerHTML = ''; }
        if (C) { C.style.display = ''; }
    }
}
function checkjiaoyou() {
    var A = document.getElementById("Phone");
    var B = document.getElementById("IM");
    if (A.value == '' && B.value == '') {
        alert("请至少填写一个联系方式");
        return false;
    }
    return true;
}
function setLineValue(data) {
    var gongjiaoxian = document.getElementById("gongjiaoxian");
    var gongjiaozhan = document.getElementById("gongjiaozhan");
    var ditiexian = document.getElementById("ditiexian");
    var ditiezhan = document.getElementById("ditiezhan");
    var university = document.getElementById("daxue");
    var hidxiaoqu = document.getElementById("hidxiaoqu");
    if (data == "") {
        if (hidxiaoqu) {
            var regStr = /^\d$/;
            var reg = new RegExp(regStr);
            if (reg.test(document.getElementById("xiaoqu").value)) {
                document.getElementById("xiaoqu").value = "@" + document.getElementById("xiaoqu").value;
            }
            hidxiaoqu.value = document.getElementById("xiaoqu").value;
        }
    }
    else {
        var dic = data.split('$');
        if (gongjiaoxian) {
            gongjiaoxian.value = getLineValue("busline", dic);
        }
        if (gongjiaozhan) {
            gongjiaozhan.value = getLineValue("busstation", dic);
        }
        if (ditiexian) {
            ditiexian.value = getLineValue("subline", dic);
        }
        if (ditiezhan) {
            ditiezhan.value = getLineValue("substation", dic);
        }
        if (university) {
            university.value = getLineValue("university", dic);
        }
        if (hidxiaoqu) {
            hidxiaoqu.value = getLineValue("DicID", dic);

        }
    }
    //$('aspnetForm').action = window.location.href;
    document.getElementById('aspnetForm').action = window.location.href + "/submit";
    document.getElementById('aspnetForm').submit();
    document.getElementById('fabu').disabled = true;
    document.getElementById('fabu').value = '正在发布...';
    //subTimerID = window.setInterval(function() { $('fabu').value = "(" + ti + ")信息正在提交中"; $('fabu').disabled = true; ti--; if (ti == 0) { clearInterval(subTimerID); ti = 10; flagSubmit = true; } else if (!flagSubmit) { clearInterval(subTimerID); ti = 10; $('fabu').value = "发布"; $('fabu').disabled = false; flagSubmit = true; } }, 1000);
}
function getLineValue(A, B) {
    try {
        for (var C = 0; C < B.length; C++) {
            var H = B[C].split('_');
            if (A.toLowerCase() == H[0].toLowerCase()) {
                var h = H[1];
                if (h) {
                    return h;
                }
            }
        }
        return "";
    }
    catch (ex) {
        return "";
    }
}
function showBizTip() {
    document.getElementById("biz_message").innerHTML = "";
    document.getElementById("biz_message").className = "chenggong";
}

function setRadioTipChenggong(obj) {
    document.getElementById(obj.name + "_message").innerHTML = "";
    document.getElementById(obj.name + "_message").className = "chenggong";
}

function setDateTipChenggong(obj) {
    var usermsg = $("#"+obj.id).attr("usermsg");
    document.getElementById(usermsg + "_message").innerHTML = "";
    document.getElementById(usermsg + "_message").className = "chenggong";
}

function showVerifyCode() {
    var inputCode = '<input type="text" qtb="true" class="text2" name="codeText" id="codeText" onblur="checkCode(this.value,true)" onfocus="checkCode(this.value)" onkeyup="checkCode(this.value)" maxlength="5" /><span id="codeText_message"></span><br>';
    document.write(inputCode);
    var datenow = new Date();
    document.write('<img src="/code?infoid=' + finfoid + '&date=' + datenow.getMinutes() + datenow.getSeconds() + datenow.getMilliseconds() + '" style="vertical-align: middle" id="cm" /><a href="javascript:reloadImg(\'cm\')">看不清？</a>');
}
function QuanToBan(val) {
    if (!val || val == '') {
        return;
    }
    var result = "";
    for (var i = 0; i < val.length; i++) {
        if (val.charCodeAt(i) == 12288) {
            result += String.fromCharCode(val.charCodeAt(i) - 12256);
            continue;
        }
        if (val.charCodeAt(i) > 65280 && val.charCodeAt(i) < 65375)
        { result += String.fromCharCode(val.charCodeAt(i) - 65248); }
        else { result += String.fromCharCode(val.charCodeAt(i)); }
    }
    return result;
}

function initProgress(num) {
    var obj = $("#GGS_UploadProgress0_" + num)[0];
    var w = Math.round(Math.random() * 10) + 3;
    if (obj != null) {
        w = obj.style.width.toString().replace("%", "");
        w = Number(w) + Math.round(Math.random() * 10);
        if (w < 100) {
            $("#GGS_UploadProgress_" + num).html('<div style="border:solid 1px #ccc; display:block;width:104px; float:left;"><div id="GGS_UploadProgress0_' + num + '" style="background-color:#99ccff; text-align:center; width:' + w + '%;">&nbsp;' + w + '%</div></div>');
        }
    }
    else {
        $("#GGS_UploadProgress_" + num).html('<div style="border:solid 1px #ccc; display:block;width:104px; float:left;"><div id="GGS_UploadProgress0_' + num + '" style="background-color:#99ccff; text-align:center; width:' + w + '%;">&nbsp;' + w + '%</div></div>');
    }
}

function setControlDispay(objid, dispayState, cateid) {
    var arrids = cateid.split(',');
    for (var i = 0; i < arrids.length; i++) {
        if (location.toString().indexOf("/" + arrids[i] + "/s5") > -1) {
            document.getElementById(objid).style.display = dispayState;
        }
    }
}

function writeUserName() {
    if (!(document.cookie != null && document.cookie != '' && document.cookie != 'undefined')) {
        var exp = new Date(); exp.setTime(exp.getTime() + 30 * 24 * 60 * 60 * 1000);
        document.cookie = "supportcookie=true;domain=58.com;expires=" + exp.toGMTString();
        if (!(document.cookie != null && document.cookie != '' && document.cookie != 'undefined')) {
            document.write('<script type="text/javascript" src="http://user.58.com/UserLoginState.ashx"></script>');
            return true;
        }
    }
    var host = window.location.hostname;
    var hosthome = host.substr(0, host.indexOf("."));
    var outurl = window.location.href;
    var str = '<a href="javascript:void(0);" onclick="showLogBox();return false;">登录</a> <a href="http://my.58.com/reg/?city=' + hosthome + '" target="_self">注册</a>';
    try {  if (GetCookieValue("UserName") != "") {
            var msgcount = parseInt(GetCookieValue("MsgUnReadTotal")) + parseInt(GetCookieValue("SystemUnReadTotal")) + parseInt(GetCookieValue("RequireFriendUnReadTotal")) + parseInt(GetCookieValue("CommentUnReadTotal"));
            if (msgcount > 0) {
                str = '<a href="http://my.58.com/' + GetCookieValue("UserID") + '/">' + GetCookieValue("UserName") + '</a> <img alt="站内消息" hspace="4" src="http://pic2.58.com/images/icoMail_open.gif" /><a  href="http://my.58.com/Liuyanjieshou/">(' + msgcount + ')</a> <a href="http://my.58.com/" target="_self">用户中心</a> <a href="http://my.58.com/ajax/loginout/?path=' + outurl + '" target="_self">退出</a>';
            }
            else {
                str = '<a href="http://my.58.com/' + GetCookieValue("UserID") + '/">' + GetCookieValue("UserName") + '</a> <img alt="站内消息" hspace="4" src="http://pic.58.com/images/icoMail.gif" /><a  href="http://my.58.com/Liuyanjieshou/">(' + msgcount + ')</a> <a href="http://my.58.com/" target="_self">用户中心</a> <a href="http://my.58.com/ajax/loginout/?path=' + outurl + '" target="_self">退出</a>';
            }
        }
        document.write(str);
        return true;
    }
    catch (e) { document.write(str); return true; }
}
function GetCookieValue(name) { var arr = document.cookie.match(new RegExp(name + "=([^&;]+)")); if (arr != null) { return decodeURI(arr[1]); } return ""; }
function writeCookie(name, value, domain, day, path) {
    var cookie = name + "=" + escape(value) + ";";
    if (domain && domain != '') {
        cookie = cookie + "domain=" + domain + ";";
    }
    if (day && day > 0) {
        var exp = new Date();
        exp.setTime(exp.getTime() + (86400 * 1000 * day));
        cookie = cookie + "expires=" + exp.toGMTString() + ";";
    }
    if (path && path != '') {
        cookie = cookie + "path=" + path + ";";
    }
    document.cookie = cookie;
}

function writeLoginState() {
    var logStateString = "";
    if (userid != "login") {
        logStateString = "<a href='javascript:void(0);' onclick='showLogBox();return false;'>登陆</a>"
    }
    else {
        logStateString = "<a href='http://my.58.com'>个人中心</a>";
    }
    document.write(logStateString);
}

function showLogBox() {
    setbg('用户登录', 410, 250, 'http://my.58.com/SimLogin/?type=loginclose');
}

function getSubLocal(parentId, obj, defVal) {
    if (parentId < 1) return;
    var urllink = "/ajax?";
    var post = "&action=getLocal&";
    post += "lid=" + parentId + "&";
    post += "defautValue=" + defVal + "&";
    post += "&rand=" + new Date();
    urllink += post;
    $.post(urllink, { action: "getLocal", lid: parentId, defautValue: defVal, rand: new Date() },
        function(data, textStatus) {
            if (obj.id.toLowerCase().indexOf("area") > -1) { getAreaResponseText(data.toString(), obj, defVal); } else { getDiduanResponseText(data.toString(), obj, defVal); }
        }, "html");
}

function getAreaResponseText(text, obj, defVal) {
    clearSelectOptions(obj);
    addOptions(obj, "区域:-1|" + text, defVal);
}
function getDiduanResponseText(text, obj, defVal) {
    clearSelectOptions(obj);
    if (text != "") {
        addOptions(obj, "地段:-1|" + text, defVal);
    }
    else {
        var a = document.getElementById("localArea");
        addOptions(obj, a.options[a.selectedIndex].text + ":" + a.value, a.value);
        changeDiduan(a.value);
    }
}
function addOptions(obj, opTV, defVal) {
    var tvs = opTV.split('|');
    for (var i = 0; i < tvs.length; i++) {
        if (tvs[i] != "") {
            var tv = tvs[i].split(':');
            if (tv.length == 2) {
                var op = new Option(tv[0], tv[1]);
                obj.options.add(op);
                if (defVal > 0 && op.value == defVal) { op.selected = "selected"; }
            }
        }
    }
}
function changeArea(v) {
    var localDiduan = document.getElementById("localDiduan");
    if (v == undefined || v == null) { v = document.getElementById("localArea").options[0].value; }
    if (v > 0) {
        getSubLocal(v, localDiduan);
    }
    else {
        clearSelectOptions(localDiduan);
        var op = new Option("地段", "0");
        localDiduan.options.add(op);
        document.getElementById("hidLocal").value = "0";
        clearErrTip(document.getElementById("locol_message"));
    }
}
function changeDiduan(v) {
    if (v == null) {
        v = document.getElementById("localDiduan").value;
    }
    document.getElementById("hidLocal").value = v;
    clearErrTip(document.getElementById("locol_message"));
}

function clearSelectOptions(obj) {
    obj.options.length = 0;
}

function checkVipPost() {
    var result = true;
    var pic = document.getElementById("Pic");
    var picMsg = document.getElementById("Pic_message");
    if (pic.value == "") {
        showErrTip(picMsg, "请上传图片");
        scrollToElement(picMsg);
        result = false;
    }
    else {
        clearErrTip(picMsg);
    }
    var hidxiaoqu = document.getElementById("hidxiaoqu");
    var xq = document.getElementById("xiaoqu");
    hidxiaoqu.value = xq.value;
    if (hidxiaoqu.value == "" || hidxiaoqu.value == undefined) {
        showErrTip(document.getElementById("xiaoqu_message"), "小区不能为空");
        scrollToElement(xq);
        result = false;
    }
    return result;
}

function showErrTip(obj, msg) {
    obj.className = "wrong";
    obj.innerHTML = msg;
}
function clearErrTip(obj) {
    if (obj) {
        obj.className = "";
        obj.innerHTML = "";
    } 
}

function scrollToElement(obj) {
    try {
        var t = obj.offsetTop; var l = obj.offsetLeft;
        while (obj = obj.offsetParent) {
            t += obj.offsetTop;
            l += obj.offsetLeft;
        }
        if (parent)
        { parent.window.scrollTo(l, t); }
        else {
            window.scrollTo(l, t);
        }
    }
    catch (E) {
        window.scrollTo(0, 0);
    }
}

function IsSupportFlash(ver) {
    if (!(ver && ver != '')) {
        ver = '9.0.45';
    }
    var playerVersion = [0, 0, 0], d = null;
    if (typeof navigator.plugins != undefined && typeof navigator.plugins["Shockwave Flash"] == "object") {
        d = navigator.plugins["Shockwave Flash"].description;
        if (d && !(typeof navigator.mimeTypes != undefined && navigator.mimeTypes["application/x-shockwave-flash"] && !navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)) {
            d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
            playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
            playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
            playerVersion[2] = /r/.test(d) ? parseInt(d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
        }
    }
    else if (typeof window.ActiveXObject != undefined) {
        var a = null, fp6Crash = false;
        try {
            a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash" + ".7");
        }
        catch (e) {
            try {
                a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash" + ".6");
                playerVersion = [6, 0, 21];
                a.AllowScriptAccess = "always";
            }
            catch (e) {
                if (playerVersion[0] == 6) {
                    fp6Crash = true;
                }
            }
            if (!fp6Crash) {
                try {
                    a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
                }
                catch (e) { }
            }
        }
        if (!fp6Crash && a) {
            try {
                d = a.GetVariable("$version");
                if (d) {
                    d = d.split(" ")[1].split(",");
                    playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
                }
            }
            catch (e) { }
        }
    }
    var v = ver.split(".");
    v[0] = parseInt(v[0], 10);
    v[1] = parseInt(v[1], 10) || 0;
    v[2] = parseInt(v[2], 10) || 0;
    return (playerVersion[0] > v[0] || (playerVersion[0] == v[0] && playerVersion[1] > v[1]) || (playerVersion[0] == v[0] && playerVersion[1] == v[1] && playerVersion[2] >= v[2])) ? true : false;
}
var __isNewUploadVersion = IsSupportFlash('') ? true : false;
function showFileUploadSpan(t) {
    var spanNewUpload = document.getElementById("spanNewUpload");
    var spanOldUpload = document.getElementById("spanOldUpload");
    var imagedomain = "http://pic.58.com";
    if (t == "new") {
        //if (!IsSupportFlash('')) {
            t = "old";
        //}
    }
    if (t == "old") {
        __isNewUploadVersion = false;
        //if (!IsSupportFlash('')) {
        if (true) {
            $("#olduploadlink").css("display", "none");
        }
        spanOldUpload.style.display = "";
        spanNewUpload.style.display = "none";
        var pics = document.getElementById("Pic").value.split("|");
        var j = 0;
        for (var i = 0; i < 4; i++) {
            eval("document.getElementById('GGS_UploadImg_" + i + "').src = '/img/nopic2.gif';");
            eval("document.getElementById('PicList_" + i + "').value = '/img/nopic2.gif';");
            eval("document.getElementById('GGS_spanCover_" + i + "').style.display = 'none';");
            eval("document.getElementById('GGS_Upload_A" + i + "').style.display = 'none';");
            eval("document.getElementById('GGS_UploadInput_" + i + "').style.display = '';");
            eval("document.getElementById('GGS_UploadInput_" + i + "').disabled='';");
            eval("document.getElementById('GGS_UploadProgress_" + i + "').innerHTML ='';");
            eval("document.getElementById('GGS_UploadMsg_" + i + "').innerHTML ='';");
            eval("document.getElementById('GGS_UploadInput_" + i + "').value ='';");
            eval("document.getElementById('GGS_spanCover_" + i + "').childNodes[0].checked = false;");
        }
        for (var i = 0; i < pics.length; i++) {
            if (pics[i] != "") {
                eval("document.getElementById('GGS_UploadImg_" + j + "').src = '" + imagedomain + pics[i] + "';");
                eval("document.getElementById('PicList_" + j + "').value = '" + imagedomain + pics[i] + "';");
                eval("document.getElementById('GGS_spanCover_" + j + "').style.display = '';");
                eval("document.getElementById('GGS_Upload_A" + j + "').style.display = '';");
                eval("document.getElementById('GGS_UploadInput_" + j + "').style.display = 'none';");
                j++;
            }
        }
    }
    else if (t == "new") {
        __isNewUploadVersion = true;
        spanNewUpload.style.display = "";
        spanOldUpload.style.display = "none";
        try {
            initPic(document.getElementById("Pic").value);
        } catch (ee) { }
    }
    else {
        spanNewUpload.style.display = "none";
        spanOldUpload.style.display = "none";
        initPic(document.getElementById("Pic").value);
        $("#btnUploadpic").css("display", "block");
    }
    try {
        document.getElementById("fileUpload").ClearFileUpload()
        thisMovie("fileUpload").ClearFileUpload();
    }
    catch (eee) {}
}
function UploadComplete(fn) {
    var d = new Date();
    var mon = d.getMonth() + 1;
    var imagedomain = "http://pic.58.com";
    var path = "/images/postimg08/big/" + d.getFullYear() + "-0" + mon.toString() + "-" + d.getDate() + "/";
    if (mon > 9) path = "/images/postimg08/big/" + d.getFullYear() + "-" + mon.toString() + "-" + d.getDate() + "/"
    var tmp = '<li class="oldli"><img width="120" height="120" src="{pic}" id="{fid}"><br>' +
                        '<input type="hidden" id="PicList" value="/img/nopic2.gif"><span style="clear: both;"></span>' +
                        '<span style="vertical-align: bottom;"><label id="GGS_spanCover"><input type="radio" onclick="setCover(\'{pic}\')"' +
                        'name="GGS_PicCover2" style="width: auto; vertical-align: top;">封面</label>&nbsp;&nbsp;&nbsp;</span>' +
                        '<a id="del_{fid}" onclick="delPic(\'{fid}\',\'{pic}\')" href="javascript://" style="vertical-align: bottom;">删除</a></li>';
    var pics = fn.split("|");
    for (var i = 0; i < pics.length; i++) {
        if (pics[i] != null && pics[i] != "" && pics[i] != "null") {
            var fid = pics[i].split('.')[0];

            document.getElementById("ulFlashUpload").innerHTML = document.getElementById("ulFlashUpload").innerHTML + tmp.replace(/{pic}/g, imagedomain + path + pics[i]).replace(/{fid}/g, fid);
            document.getElementById("Pic").value += "|" + path + pics[i];
        }
    }

    var seted = false;
    var setCoverRadio = document.getElementsByName("GGS_PicCover2");
    for (var i = 0; i < setCoverRadio.length; i++) {
        if (setCoverRadio[i].checked) { seted = true; break; }
    }
    if (!seted) { if (setCoverRadio.length > 0) { setCoverRadio[0].checked = true; setCover(document.getElementById("GGS_UploadImg").src); } }
}
function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return document.getElementById(movieName);
    } else {
        return document[movieName];
    }
}
function delPic(objid, pic) {
    var obj = document.getElementById("del_" + objid);
    if (pic == null || pic == undefined) {
        pic = document.getElementById(objid).src;
    }
    try {
        pic = fixPicString(pic);
        fixPicString();
        var hidPic = document.getElementById("Pic");
        hidPic.value = hidPic.value.toLowerCase().replace(pic + "|", "").replace("|" + pic, "").replace(pic, "");
        fixPicString();

        try {
            thisMovie("fileUpload").DeletePic(pic);
        }
        catch (eee) { }
        obj.parentNode.style.display = "none";
        obj.parentNode.innerHTML = "";
    }
    catch (eee) { }
}
function setCover(pic) {
    pic = fixPicString(pic);
    fixPicString();
    var tmp = document.getElementById("Pic").value;
    tmp = tmp.replace(pic, "");
    tmp = pic + "|" + tmp;
    document.getElementById("Pic").value = tmp;
    fixPicString();
}
function initPic(picLst) {
}
function fixPicString(pic) {
    var hidPic = document.getElementById("Pic");
    var tmp = hidPic.value.toLowerCase();
    if (pic) { tmp = pic; }
    tmp = tmp.replace(/http:\/\/pix\.58\.com/g, "");
    tmp = tmp.replace(/http:\/\/pic\.58\.com/g, "");
    tmp = tmp.replace(/http:\/\/post\.58\.com/g, "");
    tmp = tmp.replace(/\/img\/nopic2\.gif/g, "");
    tmp = tmp.replace(/(^\|*)|(\|*$)/g, "");
    tmp = tmp.replace(/\|\|/g, "|");
    var arr = tmp.split('|');
    if (arr.length > 8) {
        tmp = "";
        for (var i = 0; i < 8; i++) {
            tmp += arr[i] + "|";
        }
    }
    if (pic) { return tmp; }
    else { hidPic.value = tmp.replace(/(^\|*)|(\|*$)/g, ""); }
}
function getFileLeftCount() {
    try {
        fixPicString();
        var count = 8;
        var j = 0;
        var pics = document.getElementById("Pic").value.split('|');
        for (var i = 0; i < pics.length; i++) {
            if (pics[i] != "" && pics[i].indexOf("nopic2") == -1) {
                j++;
            }
        }
        return count - j;
    } catch (ee) { }
}